#include<bits/stdc++.h>
using namespace std;
int speedout(int Vzero,int A,int S)
{
	if(A==0) return Vzero*Vzero;
	else return (Vzero*Vzero+2*A*S);
}
int main()
{
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	int t;
	cin>>t;
	while(t--)
	{
		int n,m,L,V;
		cin>>n>>m>>L>>V;
		int d[n+3],v[n+3],a[n+3];
		for(int i=0;i<n;i++)
		{
			cin>>d[i]>>v[i]>>a[i];
		}
		int p[m+3];
		for(int i=0;i<m;i++)
		{
			cin>>p[i];
		}
		int ans=0;
		for(int i=0;i<n;i++)
		{
			if(speedout(v[i],a[i],p[m-1]-d[i])>V*V&&d[i]<=p[m-1])
			{
				ans++;
			}
		}
		cout<<ans<<" "<<(ans==0?m:m-1)<<endl;
	}
	return 0;
}
